<?php
  
class UsersController extends AppController 
{ 
  var $name = 'Users'; 

  var $components = array('Acl'); 

  function register() 
  { 
     if(!empty($this->data)) 
     { 
        $this->User->data = $this->data; 

        if ($this->User->validates()) 
        { 
           if ($this->User->save()) 
           { 
               $aro = new Aro(); 
               $parent = $aro->findByAlias('User'); 
               $parentId = $parent['aro']['id']; 

               $aro->create(); 
               $alias = $this->User->name.'::'.$this->User->id;
                
               $aro->save( 
	             'model'       => $this->User, 
                 'foreign_key' => $this->User->id, 
                 'parent_id'   => $parentId, 
                 'alias'   => $alias 
                     ); 

               $aco = new Aco(); 
               $parent = $aco->findByAlias('User'); 
               $parentId = $parent['aco']['id']; 

               $aco->create(); 
               $aco->save( 
                 'model'       => $this->User->name, 
                 'foreign_key' => $this->User->id, 
                 'parent_id'   => $parentId, 
                 'alias'       => $alias 
                       ); 

               $this->Acl->allow( 
                    $alias,  
                    $alias,  
                    array('read','update')); 
           } 
        } 
  
     } 
  } 
} 
?>